#include "StateMan.h"

using namespace std;
using namespace cocos2d;

void CStateManager::handleState( int state )
{
	 map<int,SEL_STATE_HANDLER>::iterator itera = m_mapStateHandler.find(state);
	if (itera != m_mapStateHandler.end())
	{
		SEL_STATE_HANDLER func = (SEL_STATE_HANDLER)itera->second;
		(m_owner->*func)();
	}
}

void CStateManager::handleState()
{
	handleState(m_nState);
}

void CStateManager::addStateHandler(int state, SEL_STATE_HANDLER func)
{
	m_mapStateHandler.insert(pair<int,SEL_STATE_HANDLER>(state,func));
}

